<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html {
            height: 100%;
        }

        body {
            background: url(img/login-background.jpg);
            height: 100%;
        }

        .box {
            width: 400px;
            height: 300px;
            background-color: white;
            border-radius: 10px;
            margin: 100px auto;
        }

        .houtai {
            width: 400px;
            height: 80px;
            text-align: center;
            line-height: 80px;
        }

        .nei div {
            margin-left: 70px;
            margin-top: 10px;
        }

        .nei input {
            width: 250px;
            height: 30px;
            border: 1px solid #eee;
            border-radius: 5px;
        }

        button {
            width: 250px;
            height: 30px;
            background-color: dodgerblue;
            color: white;
            border: none;
            margin-left: 70px;
            border-radius: 5px;
            margin-top: 5px;
        }

        .cl a {
            margin-left: 140px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="houtai">后台管理系统</div>
        <div class="nei">
            <div><input type="text" placeholder="账号"></div>
            <div><input type="password" placeholder="密码"></div>
            <div><input type="password" placeholder="确认密码"></div>
            <button>注册</button>
            <div class="cl"><a href="./denglu.html">使用已有账户登陆</a></div>
        </div>
    </div>
</body>

</html>
<script src="./axios.min.js"></script>
<script>
    var input = document.querySelectorAll('input')
    var btn = document.querySelector('button')
    btn.onclick = function () {
        if (input[0].value && input[1].value) {
            if (input[1].value == input[2].value) {
                axios.post('/api/register', { hao: input[0].value, pass: input[1].value }).then((res) => {
                    if (res.data.code == 200) {
                        alert(res.data.msg)
                        location.href = './denglu.html'
                    } else {
                        alert(res.data.msg)
                    }
                })
            } else {
                alert('输入两次密码不一致')
            }
        } else {
            alert('输入信息不能为空！')
        }
    }
</script>